#delimit;

use 20161021_Working_hh_1014.dta, clear;


collapse (count) n=Y, by(FIPS);

merge 1:1 FIPS using 20161021_State_Parameters_w_Var.dta;

gen SE_A=sqrt(V_A);
gen SE_B1=sqrt(V_B1);
gen SE_B2=sqrt(V_B2);

keep State n A SE_A B1 SE_B1 B2 SE_B2 TAU_2 SD_TAU R_2 SD_R_2;
order State n A SE_A B1 SE_B1 B2 SE_B2 TAU_2 SD_TAU R_2 SD_R_2;

export excel using "20161021_stateParameterTable.xlsx", first(variables) replace;